package io.zhaocy.springbootenable.annotation;

import java.lang.reflect.Method;

/**
 * Description:
 *
 * @Author: genezhao
 * @Date: 2018-07-13
 */
public class MyAnnoTest {

    @MyAnno(str = "Anno test", val = 100)
    public static void myMethod() {
        MyAnnoTest myt = new MyAnnoTest();

        Class<?> c = myt.getClass();
        try {
            Method m = c.getMethod("myMethod");

            MyAnno anno = m.getAnnotation(MyAnno.class);

            System.out.println(anno.str() + " " + anno.val());
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
    }

    @MyAnno(str="Two params", val = 19)
    public static void myMethod2(String str, int i) {
        MyAnnoTest mat = new MyAnnoTest();

        Class<?> c = mat.getClass();

        try {
            Method m = c.getMethod("myMethod2", String.class, int.class);
            MyAnno ma = m.getAnnotation(MyAnno.class);

            System.out.println(ma.str() + " " + ma.val());
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
    }




    public static void main(String[] args) {
        myMethod();

        myMethod2("test22",10);
    }
}
